package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealDishMapper {

    @Select("select count(*) from setmeal_dish where dish_id = #{dishId}")
    Integer countByDishId(Long dishId);


    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteSetmealDishByid(Long setmealId);

    void insertBatch(List<SetmealDish> setmealDishs);

    @Select("select * from setmeal_dish where setmeal_id = #{setmealId} ")
    List<SetmealDish> selectBySetmealId(Long setmealId);

    @Select("select d.* from dish d, setmeal_dish sd where sd.dish_id = d.id and  sd.setmeal_id = #{setmealId}")
    List<Dish> selectSetmealDishById(Long setmealId);

    void deleteBatch(List<Long> setmealIds);

    @Select("select * from setmeal_dish sd left join dish d on sd.dish_id = d.id where setmeal_id = #{setmealId}")
    List<DishItemVO> selectUserSetmealDishById(Long setmealId);
}
